home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / remote / uo40ra.zip / UOSYS.PAS < prev    next >
Pascal/Delphi Source File  |  1992-06-13  |  3KB  |  126 lines

  1. {***************************************************************************
  2. **
  3. **                             -=( UOsys )=-
  4. **                   (c) CopyRight LiveSystems 1992, 1993
  5. **
  6. ** Author    : Gerhard Hoogterp
  7. ** FidoNet   : 2:283/1.2
  8. **             2:512/146.5
  9. ** BitNet    : HOOGTERPG@HENUT5.BITNET or HOOGTERPG@UTWENTE.NL
  10. **
  11. ** SnailMail : Kremersmaten 108
  12. **             7511 LC Enschede
  13. **             The Netherlands
  14. **
  15. **
  16. **    This unit is part of the UserOn package and may be used freely in
  17. **    other programs.
  18. **
  19. **    Under no circumstances will the author (me) be held responsible for any
  20. **    damage as result of using this library. Use this unit at your own risk!
  21. **    Comments and remarks are welcome at one of the above addresses.
  22. **
  23. **
  24. ****************************************************************************}
  25.  
  26. Unit UOSys;
  27. Interface
  28. Uses Dos;
  29.  
  30.  
  31. Type UserDoesString = String[75];
  32.      UserDoesObject = Object
  33.                         DoesWhat : UserDoesString;    { The string to write   }
  34.                         SemDir   : PathStr;           { Where to write        }
  35.                         Node     : Byte;              { The nodenumber        }
  36.                         Name     : String[12];        { The UsedDoes filename }
  37.  
  38.                         { Prepare the userdoes object                         }
  39.                         Procedure Init( _Node : Byte;
  40.                                         _Does : UserDoesString;
  41.                                         _Where: PathStr);
  42.  
  43.                         { Write the _Does string to the semafore directory    }
  44.                         Procedure SetIt;
  45.  
  46.                         { Change the UserDoes string in the semaphore         }
  47.                         { directory                                           }
  48.                         Procedure ReSetIt(_Does : UserDoesString);
  49.  
  50.                         { Remove the UserDoes file                            }
  51.                         Procedure ClearIt;
  52.  
  53.                         { Read the UserDoes file from disk                    }
  54.                         Procedure GetIt(Def : UserDoesString);
  55.  
  56.                       End;
  57.  
  58. Implementation
  59.  
  60. Var Tmp : Text;
  61.  
  62.  
  63. Function Nr2Str(Nr : Word;Len : Byte):String;
  64. Var Temp : String[20];
  65. Begin
  66. Str(Nr:Len,Temp);
  67. Nr2Str:=Temp;
  68. End;
  69.  
  70. Procedure UserDoesObject.Init( _Node : Byte;
  71.                                _Does : UserDoesString;
  72.                                _Where: PathStr);
  73. Begin
  74. Node:=_Node;
  75. DoesWhat:=_Does;
  76. SemDir:=_Where;
  77. Name:='USERDOES.'+Nr2Str(Node,0);
  78. End;
  79.  
  80.  
  81. Procedure UserDoesObject.SetIt;
  82. Begin
  83. Assign(Tmp,SemDir+Name);
  84. Rewrite(Tmp);
  85. WriteLn(Tmp,DoesWhat);
  86. Close(Tmp);
  87. If IoResult<>0
  88.    Then;
  89. End;
  90.  
  91. Procedure UserDoesObject.ReSetIt(_Does : UserDoesString);
  92. Begin
  93. DoesWhat:=_Does;
  94. SetIt;
  95. End;
  96.  
  97. Procedure UserDoesObject.ClearIt;
  98. Var Try : Byte;
  99. Begin
  100. Try:=3;
  101. Repeat
  102.  Assign(Tmp,SemDir+Name);
  103.  Erase(Tmp);
  104.  If IoResult<>0
  105.     Then Dec(Try)
  106.     Else Try:=0;
  107. Until Try=0;
  108. End;
  109.  
  110. Procedure UserDoesObject.GetIt(Def : UserDoesString);
  111. Begin
  112. Assign(Tmp,SemDir+Name);
  113. Reset(Tmp);
  114. If IoResult=0
  115.    Then Begin
  116.         ReadLn(Tmp,DoesWhat);
  117.         Close(Tmp);
  118.         End
  119.    Else DoesWhat:=Def;
  120. If IoResult<>0
  121.    Then;
  122. End;
  123.  
  124. End.
  125.  
  126.